package com.star.blog.controller;


import com.star.blog.common.Result;
import com.star.blog.service.CommentService;
import com.star.blog.vo.params.CommentParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 聂建强
 * @since 2021-11-28
 */
@RestController
@RequestMapping("comments")
public class CommentController {

    @Resource
    private CommentService commentService;

    /**
     * 评论列表
     * @param id
     * @return
     */
    @GetMapping("article/{id}")
    public Result comments(@PathVariable("id") Long id){
        return commentService.commentsByArticleId(id);
    }

    /**
     * 写评论
     * @param commentParam
     * @return
     */
    @PostMapping("create/change")
    public Result comment(@RequestBody CommentParam commentParam){
        return commentService.comment(commentParam);
    }


}

